/*********************************************************************************************
 *
 *			Functon to return the tokens of string										 *
 *
 ********************************************************************************************/


#include "mystrings.h"


char * mystrtok (char *str, char *delim)
{
	static char *saveptr = NULL;							/*save ptr to sae last address*/
	char *check ;

	if (str == NULL){
		str = saveptr;									/*check for valid */
		if ( str == NULL){
			return NULL ;
		}
	}
	str = str +mystrspn (str,delim);					/* skip the delimitor in str */
	//		printf ("spn =%s \n",str);
	check = (char *) mystrpbrk (str,delim);			/* check for the delimitor */
	//	printf ("spn =%s \n",str);
	if (check ){									/* make token last char as NULL */
		saveptr = (check+1) ;
		*check = '\0' ;
		//		printf ("dest%s \n",saveptr);
	}
	else
		saveptr = check++;

	if ( str == '\0'){
		return NULL ;
	}
	//				printf ("%s \n",str);

	return str ;									/* return the token */
}




